package com.robot.member.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import com.robot.member.pojo.Cart;
import org.springframework.data.jpa.repository.Modifying;

import java.util.List;

/**
 * cart数据访问接口
 *
 * @author wuyunbin
 */
public interface CartDao extends JpaRepository<Cart, String>, JpaSpecificationExecutor<Cart> {
    /**
     * 通过storeId和memberId查找cart
     *
     * @param storeId
     * @param memberId
     * @return
     */
    public Cart findByStoreIdAndMemberIdAndDeletedAtIsNull(String storeId, String memberId);

    /**
     * 通过memberId查找全部cart
     *
     * @param memberId
     * @return
     */
    public List<Cart> findAllByMemberIdAndDeletedAtIsNullOrderByCreatedAtDesc(String memberId);

    /**
     * 通过memberId查找全部cart
     *
     * @param memberId
     * @return
     */
    @Modifying
    public void deleteAllByMemberId(String memberId);
}
